<template>
  <el-col :span="8">
    <div class="grid-content bg-purple box">
      <div class="box_img">
        <a :href="item.purl"
          ><img v-lazy="item.purl" class="lazy" alt="p1"
        /></a>
      </div>
      <div class="title">
        <div class="box_left">
          <div>
            <span class="name_a">
              <a :href="item.purl" rel="bookmark" class="name_a">{{
                item.pname
              }}</a>
            </span>
          </div>
          <div>
            <span class="name_b" href="portfolio-category.html"
              >下载量：{{ item.dcount }}</span
            >
            <span class="name_c" href="portfolio-category.html"
              >热度：{{ item.ccount }}</span
            >
          </div>
        </div>
        <div class="box_right">
          <i
            class="iconfont icon-aixin"
            @click="saveC(item.id, item.ccount)"
          ></i>
          <a :href="item.purl" download="1.jpg">
            <i
              class="iconfont icon-xiazai"
              @click="saveD(item.id, item.dcount)"
            ></i>
          </a>
          <!-- <i class="iconfont icon-xiazai" @click="saveD(item.purl)"></i> -->
        </div>
      </div>
    </div>
  </el-col>
</template>

<script>
import axios from "@/axios";
import _ from "lodash";
export default {
  name: "BArticle",
  props: ["item"],
  methods: {
    saveC: _.throttle(async function (id, count) {
      let config = {
        headers: { "Content-Type": "application/x-www-form-urlencoded" },
      };
      let result = await axios.post("/picture/saveC", { id, count }, config);
      if (result.code) {
        this.$emit("getAll");
      }
    }, 500),
    saveD: _.throttle(async function (id, count) {
      let config = {
        headers: { "Content-Type": "application/x-www-form-urlencoded" },
      };
      let result = await axios.post("/picture/saveD", { id, count }, config);
      if (result.code) {
        this.$emit("getAll");
      }
    }, 500),
  },
};
</script>

<style lang="less" scoped>
.box {
  width: 100%;
  .box_img {
    width: 100%;
    height: 16.875rem;
    overflow: hidden;
    img {
      width: 100%;
    }
  }

  .title {
    display: flex;
    justify-content: space-between;
    .box_left {
      div {
        height: 1.875rem;
        line-height: 1.875rem;
      }
      .name_a {
        font-size: 1.125rem;
        color: #de73ce;
        font-weight: 600;
        text-align: left !important;
        width: 6.25rem;
        margin-right: 0.625rem;
        white-space: nowrap;
        text-overflow: ellipsis;
        -o-text-overflow: ellipsis;
        overflow: hidden;
      }

      .name_b {
        font-size: 0.875rem;
        color: #a28787;
        font-weight: 500;
        margin-right: 0.625rem;
      }

      .name_c {
        font-size: 0.875rem;
        color: #e8e815;
        font-weight: 500;
        margin-right: 0.625rem;
      }
    }
    .box_right {
      a {
        color: rgb(250, 180, 191);
      }
      .iconfont {
        font-size: 1.375rem;
      }
      .icon-aixin:hover {
        cursor: pointer !important;
        font-size: 1.5rem;
      }
      margin: auto 0;
      i {
        margin: 0 0.3125rem;
      }
      .icon-aixin {
        color: rgb(250, 180, 191);
      }
    }
  }
}
</style>